package com.test.designPattern.ch32;

import com.test.designPattern.ch32.service.Service1;
import com.test.designPattern.ch32.service.Service2;

/**
 * @ClassName InitialContext
 * @Description InitialContext 初始化上下文
 * @Author 维康
 * @Date 2018/7/2 17:16
 * @Version 1.0
 **/
public class InitialContext {
    public Object lookup(String jndiName){
        if(jndiName.equalsIgnoreCase("SERVICE1")){
            System.out.println("Looking up and creating a new Service1 object");
            return new Service1();
        }else if (jndiName.equalsIgnoreCase("SERVICE2")){
            System.out.println("Looking up and creating a new Service2 object");
            return new Service2();
        }
        return null;
    }
}
